<?php
class models_binhluan extends connect{
	
	function _listbinhluan()
	{
		$sql = 'SELECT MaBL,MaMH,HoTen,SDT,Email,DATE_FORMAT(ThoiGian,"%H:%i:%s %d/%m%/%Y ")as ThoiGian,NoiDung,AnHien FROM binhluan';
		$this-> query_db($sql);
		return $this->fetchAll();
	}
    function _addbinhluan($MaMH,$HoTen,$SDT,$Email,$ThoiGian,$NoiDung,$AnHien)
	{
		$sql = "INSERT INTO binhluan VALUES ('','$MaMH','$HoTen','$SDT','$Email','$ThoiGian','$NoiDung', '$AnHien')";
		$this->query_db($sql);
	}
 	function addbinhluan($MaMH,$HoTen,$SDT,$Email,$ThoiGian,$NoiDung)
	{
		$sql = "INSERT INTO binhluan VALUES ('','$MaMH','$HoTen','$SDT','$Email','$ThoiGian','$NoiDung','')";
		$this->query_db($sql);
	}
	function _delbinhluan($id){
		$sql = "
				DELETE 
				FROM binhluan
				WHERE MaBL = '$id'";
		$this->query_db($sql);
	}
	function _getbinhluan($id){
		$sql = "
				SELECT MaBL,MaMH,HoTen,SDT,Email,DATE_FORMAT(ThoiGian,'%H:%i:%s %d/%m%/%Y ')as ThoiGian,NoiDung,AnHien
				FROM binhluan
				WHERE MaMH = '$id' AND AnHien=1";
		$this->query_db($sql);
		return $this->fetchAll();
	}
	function getbinhluan($id){
		$sql = "
				SELECT MaBL,MaMH,HoTen,SDT,Email,DATE_FORMAT(ThoiGian,'%H:%i:%s %d/%m%/%Y ')as ThoiGian,NoiDung,AnHien
				FROM binhluan
				WHERE MaBL = '$id'";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	function _updatebinhluan($MaMH,$HoTen,$SDT,$Email,$ThoiGian,$NoiDung,$AnHien,$id){
		$sql = "UPDATE binhluan
				SET  
					MaMH = '$MaMH',
					HoTen   = '$HoTen',
					SDT     = '$SDT',
					Email   = '$Email',
					ThoiGian= '$ThoiGian',
					NoiDung= '$NoiDung',
					AnHien = '$AnHien'
					WHERE MaBL = '$id'";
		$this->query_db($sql);
	}
}
?>